﻿using System;
using System.Linq;
using ilgolosone.DomainModel.Entities;
using ilgolosone.DomainModel.Queries;
using ilgolosone.DomainModel.Repositories;
using ilgolosone.Persistence.NH.Data.Impl;
using ilgolosone.Shared.Data;
using NUnit.Framework;
using ilgolosone.Shared.IoC;
using ilgolosone.Shared;

namespace ilgolosone.Persistence.NH.UnitTests
{
    [TestFixture]
    public class ReservationFixture : PersistenceFixtureBase
    {
        [TestFixtureSetUp]
        public void InitializeTests()
        {
            Bootstrapper.Initialize();
        }
        
        [Test]
        public void esistono_dati_di_prenotazione()
        {
            ConsumeUOW(uow =>
            {
                //var repository = new NHibernateRepository<Reservation>(uow);
                var repository = DependencyResolver.Resolve<IRepository<Reservation>>();
                repository.Any().Should().Be.True();
            });
        }

        [Test]
        public void ricerca_prenotazioni_per_data()
        {
            ConsumeUOW(uow =>
            {
                var repository = new NHibernateRepository<Reservation>(uow);
                repository.Filter(new FindReservationByDate(DateTime.Today)).Any().Should().Be.True();
            });
        }

        [Test]
        public void ricerca_prenotazioni_inesistenti_per_data()
        {
            ConsumeUOW(uow =>
            {
                var repository = new NHibernateRepository<Reservation>(uow);
                repository.Filter(new FindReservationByDate(DateTime.Today.AddDays(-1))).Any().Should().Be.False();
            });
        }
    }
}
